import Vue from 'vue'
import VueRouter from 'vue-router'
// Axios的封装
import InfoA from '@/views/AxiosA/Info.vue'
import IndexA from '@/views/AxiosA/Index.vue'
import HomeA from '@/views/AxiosA/Home.vue'
import MyA from '@/views/AxiosA/My.vue'
// 电脑
import LoginP from '@/views/pc/Login.vue'
import IndexP from '@/views/pc/Index.vue'
// 手机
import LoginM from '@/views/mobile/Login.vue'
import IndexM from '@/views/mobile/Index.vue'
import InfoM from '@/views/mobile/Info.vue'
import HomeM from '@/views/mobile/Home.vue'
import MyM from '@/views/mobile/My.vue'
import RegisterM from '@/views/mobile/Register.vue'
import PublicM from '@/views/mobile/Public.vue'
import MyPublicM from '@/views/mobile/MyPublic.vue'
import MyLikeListM from '@/views/mobile/MyLikeList.vue'

Vue.use(VueRouter)

const routesP = [
  // 重定向
  {
    path: '*',
    redirect: '/login'
  },
  // 跳转路径
  {
    path: '/login',
    component: LoginP
  },
  {
    path: '/index',
    component: IndexP
  },
]

const routesM = [
  // Axios的封装路径
	{
		path: '/infoA',
		component: InfoA
	},
  {
    path: '/homeA',
    component: HomeA,
    children: [{
      path: '/indexA',
      component: IndexA
    }, {
      path: '/myA',
      component: MyA
    }]
  },

  // 跳转路径
  {
    path: '/login',
    component: LoginM
  },
  {
    path: '/register',
    component: RegisterM
  },
	{
		path: '/info',
		component: InfoM
	},
  {
    path: '/Public',
    component: PublicM
  },
  {
    path: '/MyPublic',
    component: MyPublicM
  },
  {
    path: '/MyLikeList',
    component: MyLikeListM
  },
  {
    path: '/home',
    component: HomeM,
    children: [{
      path: '/index',
      component: IndexM
    }, {
      path: '/my',
      component: MyM
    }]
  },
]

var routes = [];
  if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
  routes = routesM
  } else {
  routes = routesP
}


const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
